<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/operateTag" prefix="o"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>订单管理</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
-->

<jsp:include page="/page/head.jsp"></jsp:include>
<script type="text/javascript">
		//页面打开加载
		$(document).ready(function(){
			
		    $('#mgrTable').datagrid({
       			height: 500,
		        pageSize: 20,//每页显示的记录条数，默认为10  
		        pageList: [10,15,20],//可以设置每页记录条数的列表
				nowrap: true,
        		border: true,  
				striped: true,
				collapsible: false,
				url:path+'/order/list.do',
				sortName: 'id',
				sortOrder: 'asc',
				remoteSort: false,
				idField:'id',
				pagination:true,
				rownumbers:true,
				toolbar:'#toolbar'
			});
			var p = $('#mgrTable').datagrid('getPager');
			$(p).pagination({   
		        beforePageText: '第',                    //页数文本框前显示的汉字  
		        afterPageText: '页    共  {pages} 页',
		        displayMsg: '当前显示  {from} - {to} 条记录   共  {total} 条记录'
		    });
			
		});
		
		//移除
		function remove(){
			var rows = $('#mgrTable').datagrid('getSelections');   //获取选中行信息
			if(rows){
				var ids = [];
				for(var i=0;i<rows.length;i++){
					ids.push(rows[i].id);
				}
				
				var submit = function (v, h, f) {
				    if (v == 'ok'){
				    	url = path +"/order/delete.do?ids="+ids.join(',')+"&t="+new Date().getTime();
						$.ajax({
						  url: url,
						  success: function(data) {
							   if(data == "1")
							   {
									$('#mgrTable').datagrid('reload');
									$('#mgrTable').datagrid('clearSelections');
									alertBox("操作成功！");
							   } else {
									alertBox("操作失败！");
							   }
						  }
						});
				    }
				    	
				    return true; //close
				};
				
				$.jBox.confirm("确定要删除吗？", "提示", submit);
				
			}else{
				alertBox("请选择需要删除的用户！");
			}
		}
		
		//刷新
		function refresh(){
			$('#mgrTable').datagrid('reload');
			$('#mgrTable').datagrid('clearSelections');
		}
		
		//根据条件进行模糊查询
		function search(){
			var username = $('#username').val();                  //获取筛选条件中的name
			var usercard = $('#usercard').val();                  //获取筛选条件中的会员卡号
			var orderid = $('#orderid').val();                    //获取筛选条件中订单号
			var starTime = $('#starTime').datebox('getValue');    
			var endTime = $('#endTime').datebox('getValue');
			var status = $('#status').val();
			$('#mgrTable').datagrid('reload',{username:username,usercard:usercard,orderid:orderid,starTime:starTime,endTime:endTime,status:status});
		}
		
		function clean(){
			$('#username').attr('value','');
			$('#usercard').attr('value','');
			$('#orderid').attr('value','');
			$('#starTime').datebox('setValue','');
			$('#endTime').datebox('setValue','');
			//$('#status').attr('value','');
		}
		
		
		//该方法用于指定操作栏的操作
		/* <a href=\"javascript:void(0);\" onclick=\"/roder/findOrderUrl.do?orderNo=('+value+')\">订单详情</a> |  */
		function operate(value){
			return '<a href=\"javascript:void(0);\" onclick=\"/order/OpenOrderNote.do?orderid=('+value+')\">备注</a>';
		}
		
		//根据订单号查询订单的跳转
		function findOrder(orderNo){
			if(orderNo!=null){
				window.location = path+"/order/findOrderUrl.do?orderNo="+orderNo;
			}else{
				alertBox("未找到该订单！");
			} 
		}
		
	</script>

</head>

<body>
	<div class="right">
		<h1>
			<b>订单管理</b><span><img src="<%=basePath%>images/right_h1bg2.jpg" width="3" height="29" /></span>
		</h1>
		<div class="ri_main">
			<table width="99%" border="0" cellspacing="0" cellpadding="4">
				<tr>
					<td style="vertical-align: middle;">
						<label>会员名称：</label> 
						<input class="easyui-validatebox" type="text" style="width:130px" name="username" id="username" /> 
						&nbsp;&nbsp;<label>会员卡号：</label>
						<input class="easyui-validatebox" type="text" style="width:130px" name="usercard" id="usercard" /> 
						&nbsp;<label>订单号：</label>
						&nbsp;&nbsp;<input class="easyui-validatebox" type="text" style="width:130px" name="orderid" id="orderid" /><br />
						<label>开始时间：</label>
						<input class="easyui-datebox" type="text" name="starTime" id="starTime" /> 
						&nbsp;&nbsp;<label>结束时间：</label>
						<input class="easyui-datebox" type="text" name="endTime" id="endTime" /> 
						&nbsp;<label>订单状态：</label>
						<select id="status" name="status" style="width:130px">
				    		<c:forEach var="dict" items="${orderStatus}">
				    			<option value="${dict.code }"> ${dict.name } </option>
				    		</c:forEach>
		    			</select>
						<input type="button" onclick="search()" value="查询" />
						<input type="button" onclick="clean()" value="清除" />
					</td>
				</tr>
			</table>
			<div id="toolbar">
				<a href="javascript:void(0);" onclick="remove()" class="easyui-linkbutton" iconCls="icon-remove">删除</a>
				<a href="javascript:void(0);" onclick="refresh()" class="easyui-linkbutton" iconCls="icon-reload">刷新</a>
			</div>
			<table id="mgrTable">
				<thead>
		 			<tr>
		 				<th field="ck" checkbox="true" />
						<th field="orderNo" width="100">订单号</th>
		 				<th field="cardid" width="95">卡号</th>
						<th field="score" width="35">积分</th>
						<th field="fare" width="35">运费</th>
						<th field="status" width="90">状态</th>
						<th field="consigneeName" width="80">收货人</th>
						<th field="consigneeTel" width="80">收货人电话</th>
						<th field="concludeTime" width="85">时间</th>
						<th field="id" formatter="operate" width="100">操作</th>
		 			</tr>
		 		</thead>
			</table>
		</div>
	</div>
</body>
</html>
